<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <canvas id="canvas" width="300" height="150"></canvas>
  <script>
    // // 点移动M 10 10 的位置，水平移80 , 垂直 h-80 回到起点处 (z)
    // var p = new Path2D("M10 10 h 80 v 80 h -80 Z");
    let canvasE = document.getElementById("canvas");
    let cxt = canvasE.getContext('2d');
    cxt.fillStyle = "green";
    cxt.fillRect(0, 0, canvasE.width, canvasE.height);
    // 平移到中点
    cxt.translate(canvasE.width * 0.5, canvasE.height * 0.5)
    cxt.fillStyle = "red";
    let angleInRadians = 45 * Math.PI / 180;
    // 旋转45度
    cxt.rotate(angleInRadians);
    cxt.fillRect(-25, -25, 50, 50);

    // cxt.fillStyle = 'black';
    // cxt.font = canvasE.height * 0.5 + "px serif"

    // cxt.translate(75, 30);
    // let angleInRadians = 45 * Math.PI / 180;
    // cxt.rotate(angleInRadians);
    // cxt.fillText("Y", 75, 30);

  </script>
</body>
</html>